package com.mvp.shq.washer.ui.web;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.mvp.shq.washer.R;
import com.mvp.shq.washer.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WebActivity extends BaseActivity<Presenter, Model> implements WebConstract.View {


    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.webView)
    WebView webView;
    private String url;
    private WebSettings webSettings;

    @Override
    public int getLayoutId() {
        return R.layout.activity_web;
    }

    @Override
    public void initView() {
        url = this.getIntent().getExtras().getString("url");
        webView.canGoBack();
        webView.canGoForward();
        webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        //支持插件

//设置自适应屏幕，两者合用
        webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
        webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小

//缩放操作
        webSettings.setSupportZoom(true); //支持缩放，默认为true。是下面那个的前提。
        webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false，则该WebView不可缩放
        webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件
        webView.loadUrl(url);
    }


    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
